package com.hw.nio.http;

import java.util.HashMap;
import java.util.Map;

public class HttpServerTest {

    public static void main(String[] args) throws InterruptedException {

        Map<String,String> map = new HashMap<>();
        map.put("Content-Type","text/plain; charset=UTF-8");
        SimpleHttpServer simpleHttpServer = new SimpleHttpServer(new HttpServlet() {
            @Override
            Response doGet(Request request, Response response) {
                System.out.println(request.url);
                response.setCode(200);
                response.setBody("哈哈哈哈哈哈哈");
                response.setHeaders(map);
                return response;
            }

            @Override
            Response doPost(Request request, Response response) {
                return response;
            }
        }, 8899);
        simpleHttpServer.start().join();
    }
}
